package cn.llyong.rpc.client.enums;

import cn.llyong.rpc.client.loadbalance.HashLoadBalance;
import cn.llyong.rpc.client.loadbalance.LoadBalance;
import cn.llyong.rpc.client.loadbalance.RandomLoadBalance;
import cn.llyong.rpc.client.loadbalance.RoundLoadBalance;

/**
 * @description:
 * @author: lvyong
 * @date: 2020年06月30日 19:57
 */
public enum LoadBalanceType {

    Round("Round", RoundLoadBalance.class),
    Random("Random", RandomLoadBalance.class),
    Hash("Hash", HashLoadBalance.class),
    ;

    private String type;
    private Class<?> clazz;

    LoadBalanceType(String type, Class<?> clazz) {
        this.type = type;
        this.clazz = clazz;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
    }

    public static LoadBalanceType getLoadBalanceEnum(String type) {
        LoadBalanceType[] values = LoadBalanceType.values();
        for (LoadBalanceType value : values) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        return null;
    }
}
